package com.redstars.generate.exception;

import com.redstars.generate.enums.ErrorCodeEnum;
import lombok.Data;
import lombok.EqualsAndHashCode;

/**
 * @author : zhouhx
 * @date : 2022/10/4 21:41
 */
@Data
@EqualsAndHashCode(callSuper = true)
public class RedstarsException extends RuntimeException{
    private static final long serialVersionUID = 1L;
    private int code;
    private String msg;

    public RedstarsException(String msg) {
        super(msg);
        this.code = ErrorCodeEnum.INTERNAL_SERVER_ERROR.getCode();
        this.msg = msg;
    }

    public RedstarsException(ErrorCodeEnum errorCode) {
        super(errorCode.getMsg());
        this.code = errorCode.getCode();
        this.msg = errorCode.getMsg();
    }

    public RedstarsException(String msg, Throwable e) {
        super(msg, e);
        this.code = ErrorCodeEnum.INTERNAL_SERVER_ERROR.getCode();
        this.msg = msg;
    }
}
